<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>敏感词</h2>
    <textarea name="" id="" cols="30" rows="10" class="text"></textarea>
    <br>
    <button class="ensure">提交</button>

    <div class="text-show"></div>

    <script>
        // 定义正则 匹配敏感词   g代表全部替换
        let reg = /傻|操|煞笔/g

        let text = document.getElementsByClassName('text')[0]
        let ensure = document.getElementsByClassName('ensure')[0]

        // 点击提交
        ensure.addEventListener('click',()=>{
                // 判断 并替换为 *
                document.getElementsByClassName('text-show')[0].innerText = text.value.replace(reg,'*')
         
            
        })
    </script>
</body>
</html>